import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayOrderVO, PayOrderForm, PayOrderQuery } from '@/api/goods/payOrder/types';

/**
 * 查询续费单列表
 * @param query
 * @returns {*}
 */

export const listPayOrder = (query?: PayOrderQuery): AxiosPromise<PayOrderVO[]> => {
  return request({
    url: '/order/payOrder/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询续费单详细
 * @param id
 */
export const getPayOrder = (id: string | number): AxiosPromise<PayOrderVO> => {
  return request({
    url: '/order/payOrder/' + id,
    method: 'get'
  });
};

/**
 * 新增续费单
 * @param data
 */
export const addPayOrder = (data: PayOrderForm) => {
  return request({
    url: '/order/payOrder',
    method: 'post',
    data: data
  });
};

/**
 * 修改续费单
 * @param data
 */
export const updatePayOrder = (data: PayOrderForm) => {
  return request({
    url: '/order/payOrder',
    method: 'put',
    data: data
  });
};

/**
 * 删除续费单
 * @param id
 */
export const delPayOrder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/payOrder/' + id,
    method: 'delete'
  });
};

/**
 * 查询续费单Code
 * @param 
 */
export const getPayOrderCode = (): AxiosPromise<PayOrderVO> => {
  return request({
    url: '/order/payOrder/getAutoItemNo',
    method: 'get'
  });
};
export default {
  list: listPayOrder,
  get: getPayOrder,
  add: addPayOrder,
  update: updatePayOrder,
  del: delPayOrder,
  getPayOrderCode: getPayOrderCode
}